<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" th:href="@{/static/layui/css/layui.css}">
    <script type="text/javascript" th:src="@{/static/jquery-2.1.4.js}"></script>
    <script type="text/javascript" th:src="@{/static/layui/layui.js}"></script>
    <script type="text/javascript" th:src="@{/static/mylayer.js}"></script>
</head>
<body>
<form id="formId" class="layui-form layui-form-pane" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">员工ID</label>
        <div class="layui-input-block">
            <input type="text" name="employeeId" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">考勤状态</label>
        <div class="layui-input-block">
            <select name="status">
                <option value="on_time">正常</option>
                <option value="late">迟到</option>
                <option value="early_leave">早退</option>
                <option value="absent">缺勤</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="button" class="layui-btn" onclick="submitForm()" lay-submit="" lay-filter="submitForm">添加</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<script>
    function submitForm() {
        $.post(
            '/attendance/add',
            $('#formId').serialize(),  // {'name':'zhansgan','password':'123'}
            function(result) {
                if (result.code == 0) {
                    mylayer.okMsg(result.msg);
                    setInterval(function() {
                        //关闭弹出框
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        //刷新父页面
                        window.parent.location.reload();
                    }, 2000)
                }
            },
            'json'
        );
    }
</script>
</body>
</html>